package com.liuqi.iot.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.liuqi.common.base.service.AbstractBaseEntityService;
import com.liuqi.iot.bean.dto.DeviceSimulationDTO;
import com.liuqi.iot.bean.query.DeviceSimulationQuery;
import com.liuqi.iot.domain.entity.DeviceSimulationEntity;
import com.liuqi.iot.domain.mapper.DeviceSimulationMapper;
import com.liuqi.iot.service.DeviceSimulationEntityService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * 模拟设备服务实现 
 * @author Coder Generator 2025-03-23 20:05:02 
 **/
@Service
public class DeviceSimulationEntityServiceImpl extends AbstractBaseEntityService<DeviceSimulationEntity, DeviceSimulationDTO, DeviceSimulationMapper, DeviceSimulationQuery> implements DeviceSimulationEntityService {
    @Override
    protected QueryWrapper<DeviceSimulationEntity> queryToWrapper(DeviceSimulationQuery query) {
        return this.createQueryWrapper()
                .eq(StringUtils.isNotBlank(query.getId()), "id", query.getId())
                .in(null != query.getIds(), "id", query.getIds())
                .and(StringUtils.isNotBlank(query.getKey()), w -> w.like("device_code", query.getKey())
                        .or(w1 -> w1.like("device_name", query.getKey())))
                .orderByDesc("create_time");
    }
}